package com.ruoyi.wechat.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.wechat.domain.Spec;
import com.ruoyi.wechat.domain.vo.AjaxResult;
import com.ruoyi.wechat.service.ISpecService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 规格接口
 * </p>
 *
 * @author YinHeng
 * @since 2024/4/2
 */
@RestController
@RequestMapping("/spec")
public class SpecController {

    @Autowired
    private ISpecService specService;

    /**
     * 查找规格
     *
     * @param req
     * @return
     */
    @GetMapping
    public AjaxResult findSpec(Spec req) {
        LambdaQueryWrapper<Spec> specQuery = new LambdaQueryWrapper<>();
        specQuery.eq(Spec::getItemId, req.getItemId());
        specQuery.eq(Spec::getTagIds, req.getTagIds());
        Spec spec = specService.getOne(specQuery);
        return AjaxResult.success(spec);
    }
}
